package com.lwm.annotationandreflection.ref;

/**
 * @author liweimin
 * @date 2020/9/25 10:47
 * @description 类什么时候初始化
 */
public class ref05 {
static {
    System.out.println("Main未被加载！");
}

    public static void main(String[] args) throws ClassNotFoundException {
    //主动引用
//        Son son = new Son();
    //反射也会主动引用
//        Class.forName("com.lwm.annotationandreflection.ref.Son");
        System.out.println(Son.b);
        System.out.println(Son.MSG);
        Son[] sons = new Son[10];
    }
}
class Father{
    static int b = 2;
    static {
        System.out.println("父类被加载");
    }
}
class Son extends Father{
    static {
        System.out.println("子类被加载");
        a = 456;
    }
    static int a = 123;
    static final int MSG = 13;
}